OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 112 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
112 ilm 1
package org.openconcerto.modules.operation.action;
2
 
3
import java.awt.event.ActionEvent;
4
import java.util.Date;
5
import java.util.List;
6
 
7
import javax.swing.AbstractAction;
8
import javax.swing.Action;
9
import javax.swing.JOptionPane;
10
 
11
import org.jopencalendar.model.JCalendarItemPart;
12
import org.openconcerto.modules.operation.JCalendarItemDB;
13
import org.openconcerto.modules.operation.MultiOperationSQLComponent;
150 ilm 14
import org.openconcerto.sql.model.SQLRowValues;
112 ilm 15
import org.openconcerto.sql.view.EditFrame;
16
import org.openconcerto.sql.view.EditPanel.EditMode;
17
import org.openconcerto.ui.FrameUtil;
18
 
19
public class RePlanAction extends AbstractAction {
20
    private List<JCalendarItemPart> selectedItems;
21
 
22
    public RePlanAction(List<JCalendarItemPart> selectedItems) {
150 ilm 23
        putValue(Action.NAME, "Replanifier");
112 ilm 24
        this.selectedItems = selectedItems;
25
    }
26
 
27
    @Override
28
    public void actionPerformed(ActionEvent e) {
29
        if (selectedItems.size() != 1) {
30
            return;
31
        }
32
        final JCalendarItemDB item = (JCalendarItemDB) selectedItems.get(0).getItem();
150 ilm 33
        final SQLRowValues r = item.getSource();
34
        if (item.isPlanned()) {
112 ilm 35
            final MultiOperationSQLComponent comp = new MultiOperationSQLComponent(item.getSourceElement());
36
            final EditFrame f = new EditFrame(comp, EditMode.MODIFICATION);
150 ilm 37
            f.selectionId(r.getID());
112 ilm 38
            comp.setDateStart((Date) selectedItems.get(0).getItem().getDtStart().getTime().clone());
39
            FrameUtil.show(f);
40
        } else {
150 ilm 41
            JOptionPane.showMessageDialog(null, "Cette intervention ne peut pas être directement replanifiée");
112 ilm 42
        }
43
 
44
    }
45
}