Skip to content

Package: TypeTableDataModel

TypeTableDataModel

nameinstructionbranchcomplexitylinemethod
TypeTableDataModel(List)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getFileAt(int)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getRowCount()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getValueAt(int, int)
M: 0 C: 26
100%
M: 1 C: 3
75%
M: 1 C: 3
75%
M: 0 C: 10
100%
M: 0 C: 1
100%
isCellEditable(int, int)
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 16
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
wrapData(List)
M: 0 C: 24
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: package gui.datamodels;
2:
3: import gui.wrapperobjects.VariableTypeWrapper;
4:
5: import java.util.ArrayList;
6: import java.util.Collections;
7: import java.util.List;
8:
9: import model.type.NamedVariableType;
10:
11: /**
12: * tableModel for typefiles.
13: *
14: * @author Phil
15: *
16: */
17: public class TypeTableDataModel extends AbstractTableDataModel {
18:         /**
19:          * the data.
20:          */
21:         private final List<VariableTypeWrapper> data;
22:         /**
23:          * the header.
24:          */
25:         private static final String[] TYPETABLEHEADER = {
26:                         basic.GuiConstants.LABELTEXT,
27:                         basic.GuiConstants.REGEXTEXT,
28:                         basic.GuiConstants.ERRMTEXT, };
29:
30:         /**
31:          * Constructor, wraps the given data into a list of wraped data and sorts the list by the
32:          * positions of entries.
33:          *
34:          * @param data
35:          * the data to initialize the table.
36:          */
37:         public TypeTableDataModel(final List<NamedVariableType> data) {
38:                 super(TYPETABLEHEADER);
39:                 this.data = this.wrapData(data);
40:                 Collections.sort(this.data);
41:         }
42:
43:         /**
44:          * Wraps a list of types.
45:          *
46:          * @param dataloc
47:          * The types to wrap.
48:          * @return A list of wrapped types.
49:          */
50:         private List<VariableTypeWrapper> wrapData(final List<NamedVariableType> dataloc) {
51:
52:                 final List<VariableTypeWrapper> wrapped = new ArrayList<VariableTypeWrapper>();
53:•                for (NamedVariableType varEnt : dataloc) {
54:                         wrapped.add(new VariableTypeWrapper(varEnt));
55:                 }
56:                 return wrapped;
57:         }
58:
59:         /**
60:          *
61:          */
62:         private static final long serialVersionUID = -1259178121590767090L;
63:
64:         @Override
65:         public int getRowCount() {
66:                 return this.data.size();
67:         }
68:
69:         @Override
70:         public boolean isCellEditable(final int r, final int c) {
71:                 return false;
72:         }
73:
74:         @Override
75:         public Object getValueAt(final int r, final int c) {
76:                 final NamedVariableType vartype = this.data.get(r).getWrappedType();
77:                 String retString = "";
78:•                switch (c) {
79:                 case 0:
80:                         retString = vartype.getName();
81:                         break;
82:                 case 1:
83:                         retString = vartype.getExpression().toStringUnresolved();
84:                         break;
85:                 case 2:
86:                         retString = vartype.getErrorMessage();
87:                         break;
88:                 default:
89:                         break;
90:                 }
91:                 return retString;
92:         }
93:
94:         /**
95:          * Returns the VariableAssignment of the row r.
96:          *
97:          * @param r
98:          * The row r.
99:          * @return the variable assignment.
100:          */
101:         public NamedVariableType getFileAt(final int r) {
102:                 return this.data.get(r).getWrappedType();
103:         }
104: }