OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 141 | Rev 153 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 141 Rev 150
Line 3... Line 3...
3
import static org.openconcerto.sql.TM.getTM;
3
import static org.openconcerto.sql.TM.getTM;
4
 
4
 
5
import java.awt.event.ActionEvent;
5
import java.awt.event.ActionEvent;
6
import java.io.IOException;
6
import java.io.IOException;
7
import java.util.ArrayList;
7
import java.util.ArrayList;
8
import java.util.Arrays;
-
 
9
import java.util.HashSet;
8
import java.util.HashSet;
10
import java.util.List;
9
import java.util.List;
11
import java.util.Set;
10
import java.util.Set;
12
 
11
 
13
import javax.swing.AbstractAction;
12
import javax.swing.AbstractAction;
Line 26... Line 25...
26
import org.openconcerto.erp.modules.ComponentsContext;
25
import org.openconcerto.erp.modules.ComponentsContext;
27
import org.openconcerto.erp.modules.DBContext;
26
import org.openconcerto.erp.modules.DBContext;
28
import org.openconcerto.erp.modules.MenuContext;
27
import org.openconcerto.erp.modules.MenuContext;
29
import org.openconcerto.erp.modules.ModuleFactory;
28
import org.openconcerto.erp.modules.ModuleFactory;
30
import org.openconcerto.modules.operation.action.LockAction;
29
import org.openconcerto.modules.operation.action.LockAction;
31
import org.openconcerto.sql.Configuration;
-
 
32
import org.openconcerto.sql.element.SQLElement;
30
import org.openconcerto.sql.element.SQLElement;
33
import org.openconcerto.sql.element.SQLElementDirectory;
31
import org.openconcerto.sql.element.SQLElementDirectory;
34
import org.openconcerto.sql.model.SQLRowValues;
32
import org.openconcerto.sql.model.SQLRowValues;
35
import org.openconcerto.sql.utils.SQLCreateTable;
33
import org.openconcerto.sql.utils.SQLCreateTable;
36
import org.openconcerto.sql.view.list.IListe;
34
import org.openconcerto.sql.view.list.IListe;
Line 43... Line 41...
43
    public static final String OPERATIONS_REPORT_TEMPLATE2_ID = "Operations Report2";
41
    public static final String OPERATIONS_REPORT_TEMPLATE2_ID = "Operations Report2";
44
    // -Dmodule.dir=../"Module Operation" -Dgestion.confFile=Configuration/main.properties -ea
42
    // -Dmodule.dir=../"Module Operation" -Dgestion.confFile=Configuration/main.properties -ea
45
    public static final String TABLE_SITE = "SITE";
43
    public static final String TABLE_SITE = "SITE";
46
    public static final String TABLE_OPERATION = "OPERATION";
44
    public static final String TABLE_OPERATION = "OPERATION";
47
 
45
 
-
 
46
    public static final Flag FREE_TIME_FLAG = new Flag("freeTime", null, "Non travaillé", "");
-
 
47
 
48
    public ModuleOperation(ModuleFactory f) throws IOException {
48
    public ModuleOperation(ModuleFactory f) throws IOException {
49
        super(f);
49
        super(f);
50
    }
50
    }
51
 
51
 
52
    @Override
52
    @Override
Line 55... Line 55...
55
        conf.getFieldMapper().addMapperStreamFromClass(ModuleOperation.class);
55
        conf.getFieldMapper().addMapperStreamFromClass(ModuleOperation.class);
56
 
56
 
57
        dir.addSQLElement(new SiteSQLElement(this));
57
        dir.addSQLElement(new SiteSQLElement(this));
58
        dir.addSQLElement(new OperationSQLElement(this));
58
        dir.addSQLElement(new OperationSQLElement(this));
59
 
59
 
60
        Configuration.getInstance().getShowAs().show("SITE", Arrays.asList("NAME"));
-
 
61
        // SQLRequestLog.setEnabled(true);
60
        // SQLRequestLog.setEnabled(true);
62
        // SQLRequestLog.showFrame();
61
        // SQLRequestLog.showFrame();
63
        TemplateManager.getInstance().register(OPERATIONS_REPORT_TEMPLATE_ID);
62
        TemplateManager.getInstance().register(OPERATIONS_REPORT_TEMPLATE_ID);
64
        TemplateManager.getInstance().register(OPERATIONS_REPORT_TEMPLATE2_ID);
63
        TemplateManager.getInstance().register(OPERATIONS_REPORT_TEMPLATE2_ID);
65
        // Translation loading
64
        // Translation loading
Line 67... Line 66...
67
    }
66
    }
68
 
67
 
69
    @Override
68
    @Override
70
    protected void setupMenu(MenuContext ctxt) {
69
    protected void setupMenu(MenuContext ctxt) {
71
        ctxt.addMenuItem(ctxt.createListAction(TABLE_SITE), "operation");
70
        ctxt.addMenuItem(ctxt.createListAction(TABLE_SITE), "operation");
72
        final SQLElement element = Configuration.getInstance().getDirectory().getElement(TABLE_OPERATION);
71
        final SQLElement element = ctxt.getElement(TABLE_OPERATION);
73
        final AbstractAction aOperations = new AbstractAction(getTM().trM("listAction.name", "element", element.getName())) {
72
        final AbstractAction aOperations = new AbstractAction(getTM().trM("listAction.name", "element", element.getName())) {
74
 
73
 
75
            @Override
74
            @Override
76
            public void actionPerformed(ActionEvent e) {
75
            public void actionPerformed(ActionEvent e) {
77
                JFrame f = new JFrame("Gérer les interventions");
76
                JFrame f = new JFrame("Gérer les interventions");
Line 158... Line 157...
158
    protected void start() {
157
    protected void start() {
159
        ImageIcon icon = new ImageIcon(DayView.class.getResource("auto.png"));
158
        ImageIcon icon = new ImageIcon(DayView.class.getResource("auto.png"));
160
        Flag.register(new Flag("planned", icon, "Planifié", ""));
159
        Flag.register(new Flag("planned", icon, "Planifié", ""));
161
        icon = new ImageIcon(LockAction.class.getResource("locked.png"));
160
        icon = new ImageIcon(LockAction.class.getResource("locked.png"));
162
        Flag.register(new Flag("locked", icon, "Verrouillé", ""));
161
        Flag.register(new Flag("locked", icon, "Verrouillé", ""));
-
 
162
        Flag.register(FREE_TIME_FLAG);
163
 
163
 
-
 
164
        final ComptaPropsConfiguration conf = ComptaPropsConfiguration.getInstanceCompta();
164
        comp = new OperationCalendarPanel();
165
        comp = new OperationCalendarPanel(conf);
165
        comp2 = new DailyOperationCalendarPanel();
166
        comp2 = new DailyOperationCalendarPanel(conf);
166
 
167
 
167
        MainFrame.getInstance().getTabbedPane().addTab("Planning", comp);
168
        MainFrame.getInstance().getTabbedPane().addTab("Planning", comp);
168
        MainFrame.getInstance().getTabbedPane().addTab("Planning journalier", comp2);
169
        MainFrame.getInstance().getTabbedPane().addTab("Planning journalier", comp2);
169
        MainFrame.getInstance().getTabbedPane().addTab("Chantiers", new GanttChantierPanel());
170
        MainFrame.getInstance().getTabbedPane().addTab("Chantiers", new GanttChantierPanel());
170
        MainFrame.getInstance().getTabbedPane().setSelectedIndex(1);
171
        MainFrame.getInstance().getTabbedPane().setSelectedIndex(1);
Line 183... Line 184...
183
    }
184
    }
184
 
185
 
185
    public static List<Long> getOperationIdsFrom(Set<JCalendarItemDB> toDelete) {
186
    public static List<Long> getOperationIdsFrom(Set<JCalendarItemDB> toDelete) {
186
        final List<Long> ids = new ArrayList<Long>();
187
        final List<Long> ids = new ArrayList<Long>();
187
        for (JCalendarItemDB jCalendarItemDB : toDelete) {
188
        for (JCalendarItemDB jCalendarItemDB : toDelete) {
188
            if (!jCalendarItemDB.getTableSource().equals(ModuleOperation.TABLE_OPERATION)) {
189
            if (jCalendarItemDB.getSourceElement().getClass() != OperationSQLElement.class) {
189
                throw new IllegalStateException("Table is not " + ModuleOperation.TABLE_OPERATION + " but " + jCalendarItemDB.getTableSource());
190
                throw new IllegalStateException("Table is not " + ModuleOperation.TABLE_OPERATION + " but " + jCalendarItemDB.getSource());
190
 
191
 
191
            }
192
            }
192
            final long sourceId = jCalendarItemDB.getSourceId();
193
            final long sourceId = jCalendarItemDB.getSource().getID();
193
            if (!ids.contains(sourceId)) {
194
            if (!ids.contains(sourceId)) {
194
                ids.add(sourceId);
195
                ids.add(sourceId);
195
            }
196
            }
196
        }
197
        }
197
        return ids;
198
        return ids;