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

(-)a/src/core/src/main/java/org/apache/jmeter/config/gui/RowDetailDialog.java (-27 / +69 lines)
Lines 21-26 import java.awt.BorderLayout; Link Here
21
import java.awt.FlowLayout;
21
import java.awt.FlowLayout;
22
import java.awt.event.ActionEvent;
22
import java.awt.event.ActionEvent;
23
import java.awt.event.ActionListener;
23
import java.awt.event.ActionListener;
24
import java.awt.event.ItemEvent;
25
import java.awt.event.ItemListener;
24
import java.util.ArrayList;
26
import java.util.ArrayList;
25
import java.util.List;
27
import java.util.List;
26
28
Lines 29-34 import javax.swing.Action; Link Here
29
import javax.swing.ActionMap;
31
import javax.swing.ActionMap;
30
import javax.swing.InputMap;
32
import javax.swing.InputMap;
31
import javax.swing.JButton;
33
import javax.swing.JButton;
34
import javax.swing.JCheckBox;
32
import javax.swing.JComponent;
35
import javax.swing.JComponent;
33
import javax.swing.JDialog;
36
import javax.swing.JDialog;
34
import javax.swing.JFrame;
37
import javax.swing.JFrame;
Lines 52-58 import net.miginfocom.swing.MigLayout; Link Here
52
/**
55
/**
53
 * Show detail of a Row
56
 * Show detail of a Row
54
 */
57
 */
55
public class RowDetailDialog extends JDialog implements ActionListener, DocumentListener {
58
public class RowDetailDialog extends JDialog implements ActionListener, DocumentListener, ItemListener {
56
59
57
    private static final long serialVersionUID = 6578889215615435475L;
60
    private static final long serialVersionUID = 6578889215615435475L;
58
61
Lines 67-73 public class RowDetailDialog extends JDialog implements ActionListener, Document Link Here
67
70
68
    private static final String UPDATE = "update"; // $NON-NLS-1$
71
    private static final String UPDATE = "update"; // $NON-NLS-1$
69
72
70
    private List<JTextComponent> dataAreas;
73
    private List<JComponent> dataComponents;
71
74
72
    private JButton nextButton;
75
    private JButton nextButton;
73
76
Lines 130-153 public class RowDetailDialog extends JDialog implements ActionListener, Document Link Here
130
        this.getContentPane().setLayout(new BorderLayout(10,10));
133
        this.getContentPane().setLayout(new BorderLayout(10,10));
131
134
132
        JPanel dataPanel = new JPanel(new MigLayout("fillx, wrap 2", "[][fill, grow]"));
135
        JPanel dataPanel = new JPanel(new MigLayout("fillx, wrap 2", "[][fill, grow]"));
133
        dataAreas = new ArrayList<>();
136
        dataComponents = new ArrayList<>();
134
137
135
        for (int i=0; i < tableModel.getColumnCount(); i++) {
138
        final int columnCount = tableModel.getColumnCount();
136
            JLabel dataLabel = new JLabel(JMeterUtils.getResString(tableModel.getColumnName(i)));
139
        final int linesPerTextArea = Math.max(5, Math.round(30 / Math.max(columnCount - 1, 1)));
140
        for (int column = 0; column < columnCount; column++) {
141
            JLabel dataLabel = new JLabel(JMeterUtils.getResString(tableModel.getColumnName(column)));
137
            dataPanel.add(dataLabel);
142
            dataPanel.add(dataLabel);
138
            if (i > 0 || tableModel.getColumnCount() == 1) {
143
            JComponent component = createComponentForRow(columnCount, linesPerTextArea, column,
139
                JSyntaxTextArea dataArea = JSyntaxTextArea.getInstance(30, 80);
144
                    tableModel.getValueAt(selectedRow, column));
140
                dataArea.getDocument().addDocumentListener(this);
145
            dataPanel.add(component);
141
                dataAreas.add(dataArea);
146
            dataLabel.setLabelFor(component);
142
                dataPanel.add(JTextScrollPane.getInstance(dataArea));
143
                dataLabel.setLabelFor(dataArea);
144
            } else {
145
                final JTextField nameTF = new JTextField("", 20);
146
                dataAreas.add(nameTF);
147
                nameTF.getDocument().addDocumentListener(this);
148
                dataPanel.add(nameTF);
149
                dataLabel.setLabelFor(nameTF);
150
            }
151
        }
147
        }
152
148
153
        setValues(selectedRow);
149
        setValues(selectedRow);
Lines 178-189 public class RowDetailDialog extends JDialog implements ActionListener, Document Link Here
178
        buttonsPanel.add(closeButton);
174
        buttonsPanel.add(closeButton);
179
        mainPanel.add(buttonsPanel, "center");
175
        mainPanel.add(buttonsPanel, "center");
180
        this.getContentPane().add(mainPanel);
176
        this.getContentPane().add(mainPanel);
181
        dataAreas.get(0).requestFocusInWindow();
177
        dataComponents.get(0).requestFocusInWindow();
182
178
183
        this.pack();
179
        this.pack();
184
        ComponentUtil.centerComponentInWindow(this);
180
        ComponentUtil.centerComponentInWindow(this);
185
    }
181
    }
186
182
183
    private JComponent createComponentForRow(final int columnCount, final int linesPerTextArea, int column, Object value) {
184
        if (column > 0 || columnCount == 1) {
185
            if (tableModel.getColumnClass(column).equals(Boolean.class)) {
186
                JCheckBox checkBox = new JCheckBox();
187
                if (value instanceof Boolean) {
188
                    checkBox.setSelected((Boolean) value);
189
                }
190
                checkBox.addItemListener(this);
191
                dataComponents.add(checkBox);
192
                return checkBox;
193
            } else {
194
                JSyntaxTextArea dataArea = JSyntaxTextArea
195
                        .getInstance(linesPerTextArea, 80);
196
                if (value instanceof String) {
197
                    dataArea.setInitialText((String) value);
198
                }
199
                dataArea.getDocument().addDocumentListener(this);
200
                dataComponents.add(dataArea);
201
                return JTextScrollPane.getInstance(dataArea);
202
            }
203
        } else {
204
            final JTextField nameTF = new JTextField("");
205
            if (value instanceof String) {
206
                nameTF.setText((String) value);
207
            }
208
            nameTF.getDocument().addDocumentListener(this);
209
            dataComponents.add(nameTF);
210
            return nameTF;
211
        }
212
    }
213
187
    /**
214
    /**
188
     * Do search
215
     * Do search
189
     * @param e {@link ActionEvent}
216
     * @param e {@link ActionEvent}
Lines 212-226 public class RowDetailDialog extends JDialog implements ActionListener, Document Link Here
212
    }
239
    }
213
240
214
    /**
241
    /**
215
     * Set TextField and TA values from model
242
     * Set dataComponents fields based on the value of the tableModel
216
     * @param selectedRow Selected row
243
     * @param selectedRow Selected row
217
     */
244
     */
218
    private void setValues(int selectedRow) {
245
    private void setValues(int selectedRow) {
219
        for (int i=0; i < tableModel.getColumnCount(); i++) {
246
        for (int i = 0; i < tableModel.getColumnCount(); i++) {
220
            final JTextComponent dataArea = dataAreas.get(i);
247
            final JComponent component = dataComponents.get(i);
221
            dataArea.setText((String)tableModel.getValueAt(selectedRow, i));
248
            if (component instanceof JTextComponent) {
222
            if (dataArea instanceof JSyntaxTextArea) {
249
                JTextComponent dataArea = (JTextComponent) component;
223
                dataArea.setCaretPosition(0);
250
                dataArea.setText((String) tableModel.getValueAt(selectedRow, i));
251
                if (dataArea instanceof JSyntaxTextArea) {
252
                    dataArea.setCaretPosition(0);
253
                }
254
            } else if (component instanceof JCheckBox) {
255
                ((JCheckBox) component).setSelected((Boolean) tableModel.getValueAt(selectedRow, i));
224
            }
256
            }
225
        }
257
        }
226
        textChanged = false;
258
        textChanged = false;
Lines 231-238 public class RowDetailDialog extends JDialog implements ActionListener, Document Link Here
231
     * @param actionEvent the event that led to this call
263
     * @param actionEvent the event that led to this call
232
     */
264
     */
233
    protected void doUpdate(ActionEvent actionEvent) {
265
    protected void doUpdate(ActionEvent actionEvent) {
234
        for (int i=0; i < tableModel.getColumnCount(); i++) {
266
        for (int i = 0; i < tableModel.getColumnCount(); i++) {
235
            tableModel.setValueAt(dataAreas.get(i).getText(), selectedRow, i);
267
            final JComponent component = dataComponents.get(i);
268
            if (component instanceof JTextComponent) {
269
                tableModel.setValueAt(((JTextComponent) component).getText(), selectedRow, i);
270
            } else if (component instanceof JCheckBox) {
271
                tableModel.setValueAt(((JCheckBox) component).isSelected(), selectedRow, i);
272
            }
236
        }
273
        }
237
        // Change Cancel label to Close
274
        // Change Cancel label to Close
238
        closeButton.setText(JMeterUtils.getResString("close")); //$NON-NLS-1$
275
        closeButton.setText(JMeterUtils.getResString("close")); //$NON-NLS-1$
Lines 264-267 public class RowDetailDialog extends JDialog implements ActionListener, Document Link Here
264
        changeLabelButton();
301
        changeLabelButton();
265
    }
302
    }
266
303
304
    @Override
305
    public void itemStateChanged(ItemEvent e) {
306
        changeLabelButton();
307
    }
308
267
}
309
}
(-)a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/gui/HTTPFileArgsPanel.java (-14 / +218 lines)
Lines 19-39 package org.apache.jmeter.protocol.http.gui; Link Here
19
19
20
import java.awt.BorderLayout;
20
import java.awt.BorderLayout;
21
import java.awt.Component;
21
import java.awt.Component;
22
import java.awt.Rectangle;
23
import java.awt.datatransfer.DataFlavor;
24
import java.awt.datatransfer.UnsupportedFlavorException;
22
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionEvent;
23
import java.awt.event.ActionListener;
26
import java.awt.event.ActionListener;
24
import java.io.File;
27
import java.io.File;
28
import java.io.IOException;
25
import java.util.Iterator;
29
import java.util.Iterator;
26
30
31
import javax.swing.AbstractButton;
27
import javax.swing.BorderFactory;
32
import javax.swing.BorderFactory;
28
import javax.swing.Box;
33
import javax.swing.Box;
29
import javax.swing.JButton;
34
import javax.swing.JButton;
30
import javax.swing.JFileChooser;
35
import javax.swing.JFileChooser;
36
import javax.swing.JOptionPane;
31
import javax.swing.JPanel;
37
import javax.swing.JPanel;
32
import javax.swing.JScrollPane;
38
import javax.swing.JScrollPane;
33
import javax.swing.JTable;
39
import javax.swing.JTable;
40
import javax.swing.JViewport;
34
import javax.swing.ListSelectionModel;
41
import javax.swing.ListSelectionModel;
35
42
36
import org.apache.commons.lang3.StringUtils;
43
import org.apache.commons.lang3.StringUtils;
44
import org.apache.jmeter.config.gui.RowDetailDialog;
37
import org.apache.jmeter.gui.util.FileDialoger;
45
import org.apache.jmeter.gui.util.FileDialoger;
38
import org.apache.jmeter.gui.util.HeaderAsPropertyRenderer;
46
import org.apache.jmeter.gui.util.HeaderAsPropertyRenderer;
39
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
47
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
Lines 72-86 public class HTTPFileArgsPanel extends JPanel implements ActionListener { Link Here
72
    /** A button for removing files from the table. */
80
    /** A button for removing files from the table. */
73
    private JButton delete;
81
    private JButton delete;
74
82
83
    private AbstractButton showDetail;
84
75
    /** Command for adding a row to the table. */
85
    /** Command for adding a row to the table. */
76
    private static final String ADD = "add"; // $NON-NLS-1$
86
    private static final String ADD = "add"; // $NON-NLS-1$
77
87
78
    /** Command for browsing filesystem to set path of selected row in table. */
88
    /** Command for browsing filesystem to set path of selected row in table. */
79
    private static final String BROWSE = "browse"; // $NON-NLS-1$
89
    private static final String BROWSE = "browse"; // $NON-NLS-1$
80
90
91
    /** Command for adding rows from the clipboard */
92
    private static final String ADD_FROM_CLIPBOARD = "addFromClipboard"; // $NON-NLS-1$
93
81
    /** Command for removing a row from the table. */
94
    /** Command for removing a row from the table. */
82
    private static final String DELETE = "delete"; // $NON-NLS-1$
95
    private static final String DELETE = "delete"; // $NON-NLS-1$
83
96
97
    /** Command for moving a row up in the table. */
98
    private static final String UP = "up"; // $NON-NLS-1$
99
100
    /** Command for moving a row down in the table. */
101
    private static final String DOWN = "down"; // $NON-NLS-1$
102
84
    private static final String FILEPATH = "send_file_filename_label"; // $NON-NLS-1$
103
    private static final String FILEPATH = "send_file_filename_label"; // $NON-NLS-1$
85
104
86
    /** The parameter name column title of file table. */
105
    /** The parameter name column title of file table. */
Lines 89-94 public class HTTPFileArgsPanel extends JPanel implements ActionListener { Link Here
89
    /** The mime type column title of file table. */
108
    /** The mime type column title of file table. */
90
    private static final String MIMETYPE = "send_file_mime_label"; //$NON-NLS-1$
109
    private static final String MIMETYPE = "send_file_mime_label"; //$NON-NLS-1$
91
110
111
    /** When pasting from the clipboard, split lines on linebreak */
112
    private static final String CLIPBOARD_LINE_DELIMITERS = "\n"; //$NON-NLS-1$
113
114
    /** When pasting from the clipboard, split parameters on tab */
115
    private static final String CLIPBOARD_ARG_DELIMITERS = "\t"; //$NON-NLS-1$
116
117
    /** Command for showing detail. */
118
    private static final String DETAIL = "detail"; // $NON-NLS-1$
92
119
93
    /**
120
    /**
94
     * Create a new HTTPFileArgsPanel as an embedded component
121
     * Create a new HTTPFileArgsPanel as an embedded component
Lines 162-168 public class HTTPFileArgsPanel extends JPanel implements ActionListener { Link Here
162
            for(HTTPFileArg file : base.getHTTPFiles()){
189
            for(HTTPFileArg file : base.getHTTPFiles()){
163
                tableModel.addRow(file);
190
                tableModel.addRow(file);
164
            }
191
            }
165
            checkDeleteAndBrowseStatus();
192
            checkButtonsStatus();
166
        }
193
        }
167
    }
194
    }
168
195
Lines 171-186 public class HTTPFileArgsPanel extends JPanel implements ActionListener { Link Here
171
     * Enable or disable the delete button depending on whether or not there is
198
     * Enable or disable the delete button depending on whether or not there is
172
     * a row to be deleted.
199
     * a row to be deleted.
173
     */
200
     */
174
    private void checkDeleteAndBrowseStatus() {
201
    private void checkButtonsStatus() {
175
        // Disable DELETE and BROWSE buttons if there are no rows in
202
        // Disable DETAILS, DELETE and BROWSE buttons if there are no rows in
176
        // the table to delete.
203
        // the table to delete.
177
        if (tableModel.getRowCount() == 0) {
204
        final boolean hasRows = tableModel.getRowCount() > 0;
178
            browse.setEnabled(false);
205
        browse.setEnabled(hasRows);
179
            delete.setEnabled(false);
206
        delete.setEnabled(hasRows);
180
        } else {
207
        showDetail.setEnabled(hasRows);
181
            browse.setEnabled(true);
182
            delete.setEnabled(true);
183
        }
184
    }
208
    }
185
209
186
    /**
210
    /**
Lines 203-208 public class HTTPFileArgsPanel extends JPanel implements ActionListener { Link Here
203
        String action = e.getActionCommand();
227
        String action = e.getActionCommand();
204
        if (action.equals(ADD)) {
228
        if (action.equals(ADD)) {
205
            addFile(""); //$NON-NLS-1$
229
            addFile(""); //$NON-NLS-1$
230
        } else if (action.equals(ADD_FROM_CLIPBOARD)) {
231
            addFromClipboard();
232
        } else if (action.equals(UP)) {
233
            moveUp();
234
        } else if (action.equals(DOWN)) {
235
            moveDown();
236
        } else if (action.equals(DETAIL)) {
237
            showDetail();
206
        }
238
        }
207
        runCommandOnSelectedFile(action);
239
        runCommandOnSelectedFile(action);
208
    }
240
    }
Lines 224-230 public class HTTPFileArgsPanel extends JPanel implements ActionListener { Link Here
224
            runCommandOnRow(command, rowSelected);
256
            runCommandOnRow(command, rowSelected);
225
            tableModel.fireTableDataChanged();
257
            tableModel.fireTableDataChanged();
226
            // Disable DELETE and BROWSE if there are no rows in the table to delete.
258
            // Disable DELETE and BROWSE if there are no rows in the table to delete.
227
            checkDeleteAndBrowseStatus();
259
            checkButtonsStatus();
228
            // Table still contains one or more rows, so highlight (select)
260
            // Table still contains one or more rows, so highlight (select)
229
            // the appropriate one.
261
            // the appropriate one.
230
            if (tableModel.getRowCount() != 0) {
262
            if (tableModel.getRowCount() != 0) {
Lines 267-273 public class HTTPFileArgsPanel extends JPanel implements ActionListener { Link Here
267
299
268
        tableModel.addRow(new HTTPFileArg(path));
300
        tableModel.addRow(new HTTPFileArg(path));
269
301
270
        checkDeleteAndBrowseStatus();
302
        checkButtonsStatus();
271
303
272
        // Highlight (select) the appropriate row.
304
        // Highlight (select) the appropriate row.
273
        int rowToSelect = tableModel.getRowCount() - 1;
305
        int rowToSelect = tableModel.getRowCount() - 1;
Lines 330-345 public class HTTPFileArgsPanel extends JPanel implements ActionListener { Link Here
330
        delete = new JButton(JMeterUtils.getResString("delete")); // $NON-NLS-1$
362
        delete = new JButton(JMeterUtils.getResString("delete")); // $NON-NLS-1$
331
        delete.setActionCommand(DELETE);
363
        delete.setActionCommand(DELETE);
332
364
333
        checkDeleteAndBrowseStatus();
365
        showDetail = new JButton(JMeterUtils.getResString("detail")); // $NON-NLS-1$
366
        showDetail.setActionCommand(DETAIL);
367
        showDetail.setEnabled(true);
368
        showDetail.addActionListener(this);
369
370
        // A button for adding new arguments to the table from the clipboard
371
        JButton addFromClipboard = new JButton(JMeterUtils.getResString("add_from_clipboard")); // $NON-NLS-1$
372
        addFromClipboard.setActionCommand(ADD_FROM_CLIPBOARD);
373
374
        JButton up = new JButton(JMeterUtils.getResString("up")); // $NON-NLS-1$
375
        up.setActionCommand(UP);
376
377
        JButton down = new JButton(JMeterUtils.getResString("down")); // $NON-NLS-1$
378
        down.setActionCommand(DOWN);
379
380
        checkButtonsStatus();
334
381
335
        JPanel buttonPanel = new JPanel();
382
        JPanel buttonPanel = new JPanel();
336
        buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
383
        buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
337
        add.addActionListener(this);
384
        add.addActionListener(this);
338
        browse.addActionListener(this);
385
        browse.addActionListener(this);
386
        addFromClipboard.addActionListener(this);
339
        delete.addActionListener(this);
387
        delete.addActionListener(this);
388
        up.addActionListener(this);
389
        down.addActionListener(this);
390
        buttonPanel.add(showDetail);
340
        buttonPanel.add(add);
391
        buttonPanel.add(add);
341
        buttonPanel.add(browse);
392
        buttonPanel.add(browse);
393
        buttonPanel.add(addFromClipboard);
342
        buttonPanel.add(delete);
394
        buttonPanel.add(delete);
395
        buttonPanel.add(up);
396
        buttonPanel.add(down);
343
        return buttonPanel;
397
        return buttonPanel;
344
    }
398
    }
345
399
Lines 364-367 public class HTTPFileArgsPanel extends JPanel implements ActionListener { Link Here
364
        pane.setPreferredSize(pane.getMinimumSize());
418
        pane.setPreferredSize(pane.getMinimumSize());
365
        return GuiUtils.emptyBorder(pane);
419
        return GuiUtils.emptyBorder(pane);
366
    }
420
    }
421
422
423
    /**
424
     * Move a row down
425
     */
426
    private void moveDown() {
427
        //get the selected rows before stopping editing
428
        // or the selected rows will be unselected
429
        int[] rowsSelected = table.getSelectedRows();
430
        GuiUtils.stopTableEditing(table);
431
432
        if (rowsSelected.length > 0 && rowsSelected[rowsSelected.length - 1] < table.getRowCount() - 1) {
433
            table.clearSelection();
434
            for (int i = rowsSelected.length - 1; i >= 0; i--) {
435
                int rowSelected = rowsSelected[i];
436
                tableModel.moveRow(rowSelected, rowSelected + 1, rowSelected + 1);
437
            }
438
            for (int rowSelected : rowsSelected) {
439
                table.addRowSelectionInterval(rowSelected + 1, rowSelected + 1);
440
            }
441
442
            scrollToRowIfNotVisible(rowsSelected[0]+1);
443
        }
444
    }
445
446
    /**
447
     * ensure that a row is visible in the viewport
448
     * @param rowIndex row index
449
     */
450
    private void scrollToRowIfNotVisible(int rowIndex) {
451
        if(table.getParent() instanceof JViewport) {
452
            Rectangle visibleRect = table.getVisibleRect();
453
            final int cellIndex = 0;
454
            Rectangle cellRect = table.getCellRect(rowIndex, cellIndex, false);
455
            if (visibleRect.y > cellRect.y) {
456
                table.scrollRectToVisible(cellRect);
457
            } else {
458
                Rectangle rect2 = table.getCellRect(rowIndex + getNumberOfVisibleRows(table), cellIndex, true);
459
                int width = rect2.y - cellRect.y;
460
                table.scrollRectToVisible(new Rectangle(cellRect.x, cellRect.y, cellRect.width, cellRect.height + width));
461
            }
462
        }
463
    }
464
465
    /**
466
     * @param table {@link JTable}
467
     * @return number of visible rows
468
     */
469
    private static int getNumberOfVisibleRows(JTable table) {
470
        Rectangle vr = table.getVisibleRect();
471
        int first = table.rowAtPoint(vr.getLocation());
472
        vr.translate(0, vr.height);
473
        return table.rowAtPoint(vr.getLocation()) - first;
474
    }
475
476
    /**
477
     *  Move a row down
478
     */
479
    private void moveUp() {
480
        //get the selected rows before stopping editing
481
        // or the selected rows will be unselected
482
        int[] rowsSelected = table.getSelectedRows();
483
        GuiUtils.stopTableEditing(table);
484
485
        if (rowsSelected.length > 0 && rowsSelected[0] > 0) {
486
            table.clearSelection();
487
            for (int rowSelected : rowsSelected) {
488
                tableModel.moveRow(rowSelected, rowSelected + 1, rowSelected - 1);
489
            }
490
491
            for (int rowSelected : rowsSelected) {
492
                table.addRowSelectionInterval(rowSelected - 1, rowSelected - 1);
493
            }
494
495
            scrollToRowIfNotVisible(rowsSelected[0]-1);
496
        }
497
    }
498
499
    private void addFromClipboard() {
500
        addFromClipboard(CLIPBOARD_LINE_DELIMITERS, CLIPBOARD_ARG_DELIMITERS);
501
    }
502
503
    /**
504
     * Add values from the clipboard
505
     * @param lineDelimiter Delimiter string to split clipboard into lines
506
     * @param argDelimiter Delimiter string to split line into key-value pair
507
     */
508
    private void addFromClipboard(String lineDelimiter, String argDelimiter) {
509
        GuiUtils.stopTableEditing(table);
510
        int rowCount = table.getRowCount();
511
        try {
512
            String clipboardContent = GuiUtils.getPastedText();
513
            if(clipboardContent == null) {
514
                return;
515
            }
516
            String[] clipboardLines = clipboardContent.split(lineDelimiter);
517
            for (String clipboardLine : clipboardLines) {
518
                String[] clipboardCols = clipboardLine.split(argDelimiter);
519
                if (clipboardCols.length > 0) {
520
                    HTTPFileArg argument = createHTTPFileArgFromClipboard(clipboardCols);
521
                    if (argument != null) {
522
                        tableModel.addRow(argument);
523
                    }
524
                }
525
            }
526
            if (table.getRowCount() > rowCount) {
527
                checkButtonsStatus();
528
529
                // Highlight (select) and scroll to the appropriate rows.
530
                int rowToSelect = tableModel.getRowCount() - 1;
531
                table.setRowSelectionInterval(rowCount, rowToSelect);
532
                table.scrollRectToVisible(table.getCellRect(rowCount, 0, true));
533
            }
534
        } catch (IOException ioe) {
535
            JOptionPane.showMessageDialog(this,
536
                    "Could not add read file arguments from clipboard:\n" + ioe.getLocalizedMessage(), "Error",
537
                    JOptionPane.ERROR_MESSAGE);
538
        } catch (UnsupportedFlavorException ufe) {
539
            JOptionPane.showMessageDialog(this,
540
                    "Could not add retrieve " + DataFlavor.stringFlavor.getHumanPresentableName()
541
                            + " from clipboard" + ufe.getLocalizedMessage(), "Error", JOptionPane.ERROR_MESSAGE);
542
        }
543
    }
544
545
    private HTTPFileArg createHTTPFileArgFromClipboard(String[] clipboardCols) {
546
        if (clipboardCols.length == 1) {
547
            return new HTTPFileArg(clipboardCols[0]);
548
        } else if (clipboardCols.length == 2) {
549
            return new HTTPFileArg(clipboardCols[0], clipboardCols[1], "");
550
        } else if (clipboardCols.length == 3) {
551
            return new HTTPFileArg(clipboardCols[0], clipboardCols[1], clipboardCols[2]);
552
        }
553
        return null;
554
    }
555
556
    /**
557
     * Show Row Detail
558
     */
559
    private void showDetail() {
560
        //get the selected rows before stopping editing
561
        // or the selected will be unselected
562
        int[] rowsSelected = table.getSelectedRows();
563
        GuiUtils.stopTableEditing(table);
564
565
        if (rowsSelected.length == 1) {
566
            table.clearSelection();
567
            RowDetailDialog detailDialog = new RowDetailDialog(tableModel, rowsSelected[0]);
568
            detailDialog.setVisible(true);
569
        }
570
    }
571
367
}
572
}
368
- 

Return to bug 65020