|
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"); |
|
15 | 15 | */ |
16 | 16 | package org.utplsql.sqldev.ui.runner; |
17 | 17 |
|
18 | | -import java.util.Collections; |
| 18 | +import java.util.Arrays; |
19 | 19 | import java.util.List; |
| 20 | + |
20 | 21 | import javax.swing.table.DefaultTableModel; |
21 | | -import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
| 22 | + |
22 | 23 | import org.utplsql.sqldev.model.runner.Expectation; |
23 | 24 | import org.utplsql.sqldev.resources.UtplsqlResources; |
24 | 25 |
|
25 | | -@SuppressWarnings("all") |
26 | 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; |
| 27 | + private static final long serialVersionUID = 8119453059788497567L; |
| 28 | + private List<Expectation> failedExpectations; |
| 29 | + private List<String> columnNames = Arrays.asList("#", UtplsqlResources.getString("RUNNER_ASSERT_DESCRIPTION_COLUMN")); |
| 30 | + |
| 31 | + public FailuresTableModel() { |
| 32 | + super(); |
| 33 | + } |
| 34 | + |
| 35 | + public void setModel(final List<Expectation> failedExpectations) { |
| 36 | + this.failedExpectations = failedExpectations; |
| 37 | + } |
| 38 | + |
| 39 | + public Expectation getExpectation(final int row) { |
| 40 | + return failedExpectations.get(row); |
| 41 | + } |
| 42 | + |
| 43 | + @Override |
| 44 | + public int getRowCount() { |
| 45 | + if (failedExpectations == null) { |
| 46 | + return 0; |
| 47 | + } |
| 48 | + return failedExpectations.size(); |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + public int getColumnCount() { |
| 53 | + return 2; |
| 54 | + } |
| 55 | + |
| 56 | + @Override |
| 57 | + public Object getValueAt(final int row, final int col) { |
| 58 | + final Expectation expectation = failedExpectations.get(row); |
| 59 | + if (expectation == null) { |
| 60 | + return null; |
| 61 | + } |
| 62 | + switch (col) { |
| 63 | + case 0: |
| 64 | + return row + 1; |
| 65 | + case 1: |
| 66 | + return expectation.getShortFailureText(); |
| 67 | + default: |
| 68 | + return null; |
| 69 | + } |
45 | 70 | } |
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; |
| 71 | + |
| 72 | + @Override |
| 73 | + public String getColumnName(final int col) { |
| 74 | + return columnNames.get(col); |
59 | 75 | } |
60 | | - switch (col) { |
61 | | - case 0: |
62 | | - return Integer.valueOf((row + 1)); |
63 | | - case 1: |
64 | | - return expectation.getShortFailureText(); |
65 | | - default: |
66 | | - return null; |
| 76 | + |
| 77 | + @Override |
| 78 | + public boolean isCellEditable(final int row, final int column) { |
| 79 | + return false; |
67 | 80 | } |
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; |
| 81 | + |
| 82 | + @Override |
| 83 | + public Class<?> getColumnClass(final int col) { |
| 84 | + switch (col) { |
| 85 | + case 0: |
| 86 | + return Integer.class; |
| 87 | + case 1: |
| 88 | + return String.class; |
| 89 | + default: |
| 90 | + return String.class; |
| 91 | + } |
90 | 92 | } |
91 | | - } |
92 | 93 | } |
0 commit comments