|
1 | | -/* |
| 1 | +/** |
2 | 2 | * Copyright 2019 Philipp Salvisberg <philipp.salvisberg@trivadis.com> |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
13 | 13 | * See the License for the specific language governing permissions and |
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | | - package org.utplsql.sqldev.ui.runner |
| 16 | +package org.utplsql.sqldev.ui.runner; |
17 | 17 |
|
18 | | -import java.util.List |
19 | | -import javax.swing.table.DefaultTableModel |
20 | | -import org.utplsql.sqldev.model.runner.Expectation |
21 | | -import org.utplsql.sqldev.resources.UtplsqlResources |
| 18 | +import java.util.Collections; |
| 19 | +import java.util.List; |
| 20 | +import javax.swing.table.DefaultTableModel; |
| 21 | +import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
| 22 | +import org.utplsql.sqldev.model.runner.Expectation; |
| 23 | +import org.utplsql.sqldev.resources.UtplsqlResources; |
22 | 24 |
|
23 | | -class FailuresTableModel extends DefaultTableModel { |
24 | | - List<Expectation> failedExpectations |
25 | | - |
26 | | - new() { |
27 | | - super() |
28 | | - } |
29 | | - |
30 | | - def setModel(List<Expectation> failedExpectations) { |
31 | | - this.failedExpectations = failedExpectations |
32 | | - } |
33 | | - |
34 | | - def getExpectation(int row) { |
35 | | - return failedExpectations.get(row) |
36 | | - } |
37 | | - |
38 | | - override getRowCount() { |
39 | | - if (failedExpectations === null) { |
40 | | - return 0 |
41 | | - } |
42 | | - return failedExpectations.size() |
43 | | - } |
44 | | - |
45 | | - override getColumnCount() { |
46 | | - return 2 |
47 | | - } |
48 | | - |
49 | | - override getValueAt(int row, int col) { |
50 | | - val expectation = failedExpectations.get(row) |
51 | | - if (expectation === null) { |
52 | | - return null |
53 | | - } |
54 | | - switch (col) { |
55 | | - case 0: { |
56 | | - return row + 1 |
57 | | - } |
58 | | - case 1: { |
59 | | - return expectation.shortFailureText |
60 | | - } |
61 | | - default: { |
62 | | - return null |
63 | | - } |
64 | | - } |
65 | | - } |
66 | | - |
67 | | - override getColumnName(int col) { |
68 | | - return #["#", UtplsqlResources.getString("RUNNER_ASSERT_DESCRIPTION_COLUMN")].get(col) |
69 | | - } |
70 | | - |
71 | | - override isCellEditable(int row, int column) { |
72 | | - return false |
73 | | - } |
74 | | - |
75 | | - override getColumnClass(int col) { |
76 | | - switch (col) { |
77 | | - case 0: { |
78 | | - return Integer |
79 | | - } |
80 | | - case 1: { |
81 | | - return String |
82 | | - } |
83 | | - default: { |
84 | | - return String |
85 | | - } |
86 | | - } |
87 | | - } |
| 25 | +@SuppressWarnings("all") |
| 26 | +public class FailuresTableModel extends DefaultTableModel { |
| 27 | + private List<Expectation> failedExpectations; |
| 28 | + |
| 29 | + public FailuresTableModel() { |
| 30 | + super(); |
| 31 | + } |
| 32 | + |
| 33 | + public List<Expectation> setModel(final List<Expectation> failedExpectations) { |
| 34 | + return this.failedExpectations = failedExpectations; |
| 35 | + } |
| 36 | + |
| 37 | + public Expectation getExpectation(final int row) { |
| 38 | + return this.failedExpectations.get(row); |
| 39 | + } |
| 40 | + |
| 41 | + @Override |
| 42 | + public int getRowCount() { |
| 43 | + if ((this.failedExpectations == null)) { |
| 44 | + return 0; |
| 45 | + } |
| 46 | + return this.failedExpectations.size(); |
| 47 | + } |
| 48 | + |
| 49 | + @Override |
| 50 | + public int getColumnCount() { |
| 51 | + return 2; |
| 52 | + } |
| 53 | + |
| 54 | + @Override |
| 55 | + public Object getValueAt(final int row, final int col) { |
| 56 | + final Expectation expectation = this.failedExpectations.get(row); |
| 57 | + if ((expectation == null)) { |
| 58 | + return null; |
| 59 | + } |
| 60 | + switch (col) { |
| 61 | + case 0: |
| 62 | + return Integer.valueOf((row + 1)); |
| 63 | + case 1: |
| 64 | + return expectation.getShortFailureText(); |
| 65 | + default: |
| 66 | + return null; |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public String getColumnName(final int col) { |
| 72 | + String _string = UtplsqlResources.getString("RUNNER_ASSERT_DESCRIPTION_COLUMN"); |
| 73 | + return Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("#", _string)).get(col); |
| 74 | + } |
| 75 | + |
| 76 | + @Override |
| 77 | + public boolean isCellEditable(final int row, final int column) { |
| 78 | + return false; |
| 79 | + } |
| 80 | + |
| 81 | + @Override |
| 82 | + public Class<?> getColumnClass(final int col) { |
| 83 | + switch (col) { |
| 84 | + case 0: |
| 85 | + return Integer.class; |
| 86 | + case 1: |
| 87 | + return String.class; |
| 88 | + default: |
| 89 | + return String.class; |
| 90 | + } |
| 91 | + } |
88 | 92 | } |
0 commit comments