OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Rev 182 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 174
Line 28... Line 28...
28
import org.openconcerto.sql.model.Where;
28
import org.openconcerto.sql.model.Where;
29
import org.openconcerto.sql.request.ListSQLRequest;
29
import org.openconcerto.sql.request.ListSQLRequest;
30
import org.openconcerto.sql.request.UpdateBuilder;
30
import org.openconcerto.sql.request.UpdateBuilder;
31
import org.openconcerto.sql.users.User;
31
import org.openconcerto.sql.users.User;
32
import org.openconcerto.sql.users.UserManager;
32
import org.openconcerto.sql.users.UserManager;
-
 
33
import org.openconcerto.sql.users.rights.TableAllRights;
33
import org.openconcerto.sql.view.FileTransfertHandler;
34
import org.openconcerto.sql.view.FileTransfertHandler;
34
import org.openconcerto.sql.view.IListener;
35
import org.openconcerto.sql.view.IListener;
35
import org.openconcerto.sql.view.list.IListeAction.ButtonsBuilder;
36
import org.openconcerto.sql.view.list.IListeAction.ButtonsBuilder;
36
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
37
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
37
import org.openconcerto.sql.view.list.IListeAction.PopupBuilder;
38
import org.openconcerto.sql.view.list.IListeAction.PopupBuilder;
Line 144... Line 145...
144
 * @author ILM Informatique
145
 * @author ILM Informatique
145
 */
146
 */
146
public final class IListe extends JPanel {
147
public final class IListe extends JPanel {
147
 
148
 
148
    static private final class LockAction extends RowAction {
149
    static private final class LockAction extends RowAction {
-
 
150
        private final boolean lock;
-
 
151
 
149
        public LockAction(final boolean lock) {
152
        public LockAction(final boolean lock) {
150
            super(new AbstractAction(TM.tr(lock ? "ilist.lockRows" : "ilist.unlockRows")) {
153
            super(new AbstractAction(TM.tr(lock ? "ilist.lockRows" : "ilist.unlockRows")) {
151
                @Override
154
                @Override
152
                public void actionPerformed(ActionEvent e) {
155
                public void actionPerformed(ActionEvent e) {
153
                    final IListe list = IListe.get(e);
156
                    final IListe list = IListe.get(e);
Line 165... Line 168...
165
                    final Collection<? extends Number> fireIDs = ids.size() < 12 ? ids : Collections.singleton(SQLRow.NONEXISTANT_ID);
168
                    final Collection<? extends Number> fireIDs = ids.size() < 12 ? ids : Collections.singleton(SQLRow.NONEXISTANT_ID);
166
                    for (final Number fireID : fireIDs)
169
                    for (final Number fireID : fireIDs)
167
                        t.fireTableModified(fireID.intValue(), update.getFieldsNames());
170
                        t.fireTableModified(fireID.intValue(), update.getFieldsNames());
168
                }
171
                }
169
            }, false, true);
172
            }, false, true);
-
 
173
            this.lock = lock;
170
        }
174
        }
171
 
175
 
172
        @Override
176
        @Override
173
        public boolean enabledFor(IListeEvent evt) {
177
        public boolean enabledFor(IListeEvent evt) {
174
            // TODO use right
178
            boolean hasRight = TableAllRights.currentUserHasRight(this.lock ? TableAllRights.USER_UI_LOCK_ROW : TableAllRights.USER_UI_UNLOCK_ROW, evt.getTable());
175
            return evt.getSelectedRows().size() > 0;
179
            return !evt.getSelectedRows().isEmpty() && hasRight;
176
        }
180
        }
177
    }
181
    }
178
 
182
 
179
    private static LockAction LOCK_ACTION;
183
    private static LockAction LOCK_ACTION;
180
    private static LockAction UNLOCK_ACTION;
184
    private static LockAction UNLOCK_ACTION;
Line 1202... Line 1206...
1202
        for (int i = start; i <= stop; i++) {
1206
        for (int i = start; i <= stop; i++) {
1203
            if (selectionModel.isSelectedIndex(i)) {
1207
            if (selectionModel.isSelectedIndex(i)) {
1204
                try {
1208
                try {
1205
                    res.add(getRow(i, clazz));
1209
                    res.add(getRow(i, clazz));
1206
                } catch (IndexOutOfBoundsException e) {
1210
                } catch (IndexOutOfBoundsException e) {
1207
                    throw new IllegalStateException(
1211
                    throw new IllegalStateException("The selected row at " + i
1208
                            "The selected row at " + i
-
 
1209
                                    + " is not in the model : it has been changed before Swing could update the selection. E.g. the DB was changed on mousePressed and Swing updated the selection on mouseReleased.",
1212
                            + " is not in the model : it has been changed before Swing could update the selection. E.g. the DB was changed on mousePressed and Swing updated the selection on mouseReleased.",
1210
                            e);
1213
                            e);
1211
                }
1214
                }
1212
            }
1215
            }
1213
        }
1216
        }
1214
        return res;
1217
        return res;