View | Details | Raw Unified | Return to bug 52085
Collapse All | Expand All

(-)ArgumentsPanel.java (-27 / +37 lines)
Lines 334-343 Link Here
334
    private void moveDown() {
334
    private void moveDown() {
335
        cancelEditing();
335
        cancelEditing();
336
336
337
        int rowSelected = table.getSelectedRow();
337
        int[] rowsSelected = table.getSelectedRows();
338
        if (rowSelected >=0 && rowSelected < table.getRowCount()-1) {
338
        if (rowsSelected.length > 0 && rowsSelected[rowsSelected.length - 1] < table.getRowCount() - 1) {
339
            tableModel.moveRow(rowSelected, rowSelected+1, rowSelected+1);
339
            table.clearSelection();
340
            table.setRowSelectionInterval(rowSelected+1, rowSelected+1);
340
            for (int i = rowsSelected.length - 1; i >= 0; i--) {
341
                int rowSelected = rowsSelected[i];
342
                tableModel.moveRow(rowSelected, rowSelected + 1, rowSelected + 1);
343
            }
344
            for (int rowSelected : rowsSelected) {
345
                table.addRowSelectionInterval(rowSelected + 1, rowSelected + 1);
346
            }
341
        }
347
        }
342
    }
348
    }
343
349
Lines 347-357 Link Here
347
    private void moveUp() {
353
    private void moveUp() {
348
        cancelEditing();
354
        cancelEditing();
349
355
350
        int rowSelected = table.getSelectedRow();
356
        int[] rowsSelected = table.getSelectedRows();
351
        if (rowSelected > 0) {
357
        if (rowsSelected.length > 0 && rowsSelected[0] > 0) {
352
            tableModel.moveRow(rowSelected, rowSelected+1, rowSelected-1);
358
            table.clearSelection();
353
            table.setRowSelectionInterval(rowSelected-1, rowSelected-1);
359
            for (int rowSelected : rowsSelected) {
354
        } 
360
                tableModel.moveRow(rowSelected, rowSelected + 1, rowSelected - 1);
361
            }
362
            for (int rowSelected : rowsSelected) {
363
                table.addRowSelectionInterval(rowSelected - 1, rowSelected - 1);
364
            }
365
        }
355
    }
366
    }
356
367
357
    /**
368
    /**
Lines 360-391 Link Here
360
    protected void deleteArgument() {
371
    protected void deleteArgument() {
361
        cancelEditing();
372
        cancelEditing();
362
373
363
        int rowSelected = table.getSelectedRow();
374
        int[] rowsSelected = table.getSelectedRows();
364
        if (rowSelected >= 0) {
375
        int anchorSelection = table.getSelectionModel().getAnchorSelectionIndex();
365
            tableModel.removeRow(rowSelected);
376
        table.clearSelection();
366
            tableModel.fireTableDataChanged();
377
        if (rowsSelected.length > 0) {
378
            for (int i = rowsSelected.length - 1; i >= 0; i--) {
379
                tableModel.removeRow(rowsSelected[i]);
380
            }
367
381
368
            // Disable DELETE if there are no rows in the table to delete.
382
            // Disable DELETE if there are no rows in the table to delete.
369
            if (tableModel.getRowCount() == 0) {
383
            if (tableModel.getRowCount() == 0) {
370
                delete.setEnabled(false);
384
                delete.setEnabled(false);
371
            }
385
            }
386
            // Table still contains one or more rows, so highlight (select)
387
            // the appropriate one.
388
            else if (tableModel.getRowCount() > 0) {
389
                if (anchorSelection >= tableModel.getRowCount()) {
390
                    anchorSelection = tableModel.getRowCount() - 1;
391
                }
392
                table.setRowSelectionInterval(anchorSelection, anchorSelection);
393
            }
372
            
394
            
373
            if(enableUpDown && tableModel.getRowCount()>1) {
395
            if(enableUpDown && tableModel.getRowCount()>1) {
374
                up.setEnabled(true);
396
                up.setEnabled(true);
375
                down.setEnabled(true);
397
                down.setEnabled(true);
376
            }
398
            }
377
378
            // Table still contains one or more rows, so highlight (select)
379
            // the appropriate one.
380
            else {
381
                int rowToSelect = rowSelected;
382
383
                if (rowSelected >= tableModel.getRowCount()) {
384
                    rowToSelect = rowSelected - 1;
385
                }
386
387
                table.setRowSelectionInterval(rowToSelect, rowToSelect);
388
            }
389
        }
399
        }
390
    }
400
    }
391
401
Lines 456-463 Link Here
456
                new Functor("setName"), // $NON-NLS-1$
466
                new Functor("setName"), // $NON-NLS-1$
457
                new Functor("setValue") }, // $NON-NLS-1$
467
                new Functor("setValue") }, // $NON-NLS-1$
458
                new Class[] { String.class, String.class });
468
                new Class[] { String.class, String.class });
459
    	}
460
    }
469
    }
470
    }
461
471
462
    public static boolean testFunctors(){
472
    public static boolean testFunctors(){
463
        ArgumentsPanel instance = new ArgumentsPanel();
473
        ArgumentsPanel instance = new ArgumentsPanel();
Lines 483-489 Link Here
483
        initializeTableModel();
493
        initializeTableModel();
484
        table = new JTable(tableModel);
494
        table = new JTable(tableModel);
485
        table.getTableHeader().setDefaultRenderer(new HeaderAsPropertyRenderer());
495
        table.getTableHeader().setDefaultRenderer(new HeaderAsPropertyRenderer());
486
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
496
        table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
487
        if (this.background != null) {
497
        if (this.background != null) {
488
            table.setBackground(this.background);
498
            table.setBackground(this.background);
489
        }
499
        }

Return to bug 52085