1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1996, Vrije Universiteit Amsterdam
5
// Author: Frank Dehne (frank@cs.vu.nl).
7
// TCM is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation; either version 2 of the License, or
10
// (at your option) any later version.
12
// TCM is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with TCM; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
////////////////////////////////////////////////////////////////////////////////
26
#include "cellcolumn.h"
28
#include "messagedialog.h"
30
FETable::FETable(Config *c, FEWindow *t, FEViewer *v): Matrix(c, t, v) { }
32
bool FETable::CheckTextString(Cell *c, const string *text) {
33
if (!Matrix::CheckTextString(c, text))
35
// Check for crud entries.
36
if (c->GetRow()->GetNumber() >=1 && c->GetColumn()->GetNumber() >= 1) {
39
ShowDialog(MessageDialog::ERROR, "Error",
40
"A `CRUD' string is expected here");
46
bool FETable::IsCRUD(const string *text) {
47
bool C=False, D=False, U=False, R=False;
48
for (unsigned i=0;i<text->length();i++) {
50
case 'C': if (C) return False; C=True; break;
51
case 'D': if (D) return False; D=True; break;
52
case 'U': if (U) return False; U=True; break;
53
case 'R': if (R) return False; R=True; break;
54
default: return False;
60
unsigned FETable::CountCEntries(unsigned n) {
62
CellRow *row = GetTableViewer()->GiveRow(n);
64
if (row && (cell=row->FirstCell())) {
65
while ((cell=row->NextCell())) {
66
const string *s = cell->GetText();
67
for (unsigned i=0; i<s->length(); i++) {
76
void FETable::CheckDocument() {
79
// Check missing entity type names.
80
unsigned n = CheckEmptyRowEntries(0);
82
chkbuf += "* Error: ";
84
chkbuf += " entity type";
87
chkbuf += " in column 0 ";
88
(n == 1) ? (chkbuf += "is"): (chkbuf += "are");
89
chkbuf += " still empty\n";
92
// Check missing function names.
93
n = CheckEmptyColumnEntries(0);
95
chkbuf += "* Error: ";
97
chkbuf += " function";
100
chkbuf += " in row 0 ";
101
(n == 1) ? (chkbuf += "is"): (chkbuf += "are");
102
chkbuf += " still empty\n";
105
// Check for functions without entries (warning).
107
for (i=1; i<GetTableViewer()->GetNumberOfColumns(); i++) {
108
CellColumn *column = GetTableViewer()->GiveColumn(i);
109
if (column && *column->FirstCell()->GetText() != "") {
110
unsigned j = CheckEmptyRowEntries(i);
111
if (j == GetTableViewer()->GetNumberOfRows()-1) {
112
chkbuf += "* Warning: the function in column ";
114
chkbuf += " does not do anything\n";
115
GetTableViewer()->SelectCell(column->FirstCell());
120
// Check for entity types without a C.
121
for (i=1; i<GetTableViewer()->GetNumberOfRows(); i++) {
122
CellRow *row = GetTableViewer()->GiveRow(i);
123
if (row && *row->FirstCell()->GetText() != "") {
124
unsigned j = CountCEntries(i);
126
chkbuf += "* Warning: the entity type in row ";
128
chkbuf += " does not have a creation\n";
129
GetTableViewer()->SelectCell(row->FirstCell());
134
// Check for entries that are no CRUD strings.
135
for (i=1; i<GetTableViewer()->GetNumberOfRows(); i++) {
136
CellRow *row = GetTableViewer()->GiveRow(i);
138
j<GetTableViewer()->GetNumberOfColumns(); j++) {
140
Cell *cell = row->NthCell(j);
142
const string *s = cell->GetText();
144
chkbuf += "* Error: cell ";
148
chkbuf += " does not contain";
149
chkbuf += " a CRUD string\n";
150
GetTableViewer()->SelectCell(cell);
158
ReportCheck(total, &chkbuf);