OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 106 Rev 181
Line 5... Line 5...
5
import java.text.DecimalFormat;
5
import java.text.DecimalFormat;
6
import java.util.HashSet;
6
import java.util.HashSet;
7
import java.util.Set;
7
import java.util.Set;
8
 
8
 
9
import javax.swing.JComponent;
9
import javax.swing.JComponent;
-
 
10
import javax.swing.JLabel;
10
import javax.swing.text.AbstractDocument;
11
import javax.swing.text.AbstractDocument;
11
import javax.swing.text.JTextComponent;
12
import javax.swing.text.JTextComponent;
12
 
13
 
13
import org.openconcerto.erp.core.common.ui.DeviseField;
14
import org.openconcerto.erp.core.common.ui.DeviseField;
14
import org.openconcerto.sql.element.GroupSQLComponent;
15
import org.openconcerto.sql.element.GroupSQLComponent;
15
import org.openconcerto.sql.element.SQLElement;
16
import org.openconcerto.sql.element.SQLElement;
-
 
17
import org.openconcerto.sql.sqlobject.ElementComboBox;
16
import org.openconcerto.sql.sqlobject.itemview.VWRowItemView;
18
import org.openconcerto.sql.sqlobject.itemview.VWRowItemView;
17
import org.openconcerto.ui.JDate;
19
import org.openconcerto.ui.JDate;
18
import org.openconcerto.ui.component.ITextArea;
20
import org.openconcerto.ui.JLabelBold;
19
import org.openconcerto.ui.component.text.TextComponentUtils;
21
import org.openconcerto.ui.component.text.TextComponentUtils;
20
import org.openconcerto.ui.group.Group;
22
import org.openconcerto.ui.group.Group;
21
import org.openconcerto.utils.text.DocumentFilterList;
23
import org.openconcerto.utils.text.DocumentFilterList;
22
import org.openconcerto.utils.text.DocumentFilterList.FilterType;
24
import org.openconcerto.utils.text.DocumentFilterList.FilterType;
23
import org.openconcerto.utils.text.LimitedSizeDocumentFilter;
25
import org.openconcerto.utils.text.LimitedSizeDocumentFilter;
Line 39... Line 41...
39
            public void propertyChange(PropertyChangeEvent evt) {
41
			public void propertyChange(PropertyChangeEvent evt) {
40
                updateAmount();
42
				updateAmount();
41
            }
43
			}
42
        };
44
		};
43
 
45
 
44
        final AbstractDocument comp1 = (AbstractDocument) TextComponentUtils.getDocument(getView("TRAVEL_DISTANCE").getComp());
46
		final AbstractDocument comp1 = (AbstractDocument) TextComponentUtils
-
 
47
				.getDocument(getView("TRAVEL_DISTANCE").getComp());
45
        DocumentFilterList.add(comp1, new LimitedSizeDocumentFilter(5), FilterType.SIMPLE_FILTER);
48
		DocumentFilterList.add(comp1, new LimitedSizeDocumentFilter(5), FilterType.SIMPLE_FILTER);
46
        getView("TRAVEL_DISTANCE").addValueListener(listener);
49
		getView("TRAVEL_DISTANCE").addValueListener(listener);
47
 
50
 
48
        final AbstractDocument comp2 = (AbstractDocument) TextComponentUtils.getDocument(getView("TRAVEL_RATE").getComp());
51
		final AbstractDocument comp2 = (AbstractDocument) TextComponentUtils
-
 
52
				.getDocument(getView("TRAVEL_RATE").getComp());
49
        DocumentFilterList.add(comp2, new LimitedSizeDocumentFilter(5), FilterType.SIMPLE_FILTER);
53
		DocumentFilterList.add(comp2, new LimitedSizeDocumentFilter(5), FilterType.SIMPLE_FILTER);
50
 
54
 
51
        getView("TRAVEL_RATE").addValueListener(listener);
55
		getView("TRAVEL_RATE").addValueListener(listener);
52
    }
56
	}
53
 
57
 
Line 60... Line 64...
60
        s.add("ID_EXPENSE_STATE");
64
		s.add("ID_EXPENSE_STATE");
61
        return s;
65
		return s;
62
    }
66
	}
63
 
67
 
64
    @Override
68
	@Override
65
    public JComponent getEditor(String id) {
69
	public JComponent createEditor(String id) {
66
        if (id.equals("DESCRIPTION")) {
70
		if(id.equals("ID_USER_COMMON") || id.equals("ID_EXPENSE_STATE")) {
-
 
71
            ElementComboBox comp = new ElementComboBox(false, 15);
-
 
72
            ((ElementComboBox) comp).init(getElement().getForeignElement(id));
67
            return new ITextArea();
73
            return comp;
-
 
74
		}
68
        } else if (id.equals("DATE")) {
75
		else if (id.equals("DATE")) {
69
            return new JDate(true);
76
			return new JDate(true);
70
        } else if (id.endsWith("AMOUNT")) {
77
		} else if (id.endsWith("AMOUNT")) {
71
            return new DeviseField();
78
			return new DeviseField();
72
        }
79
		}
73
        return super.getEditor(id);
80
		return super.createEditor(id);
-
 
81
	}
-
 
82
 
-
 
83
	@Override
-
 
84
	public JLabel getLabel(String id) {
-
 
85
		if (id.equals("humanresources.travel.expense.travel")) {
-
 
86
			return new JLabelBold("Frais kilometriques");
-
 
87
		} else if (id.equals("humanresources.travel.expense.default")) {
-
 
88
			return new JLabelBold("Descriptif");
-
 
89
		} else if (id.equals("humanresources.travel.expense.misc")) {
-
 
90
			return new JLabelBold("Frais annexes");
-
 
91
		} else {
-
 
92
			return (JLabel) super.getLabel(id);
-
 
93
		}
74
    }
94
	}
75
 
95
 
76
    private void updateAmount() {
96
	private void updateAmount() {
77
        float v1 = getFloat("TRAVEL_DISTANCE");
97
		float v1 = getFloat("TRAVEL_DISTANCE");
78
        float v2 = getFloat("TRAVEL_RATE");
98
		float v2 = getFloat("TRAVEL_RATE");