|
| 1 | +/* |
| 2 | + * Copyright 2019 Philipp Salvisberg <philipp.salvisberg@trivadis.com> |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + package org.utplsql.sqldev.ui.runner |
| 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 |
| 22 | + |
| 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.description |
| 60 | + } |
| 61 | + default: { |
| 62 | + return null |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + override getColumnName(int col) { |
| 68 | + return #["#", UtplsqlResources.getString("RUNNER_DESCRIPTION")].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 | + } |
| 88 | +} |
0 commit comments