~ubuntu-branches/ubuntu/warty/tcm/warty

« back to all changes in this revision

Viewing changes to src/st/tdtable.c

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////////////////////////////////////////////////////////////////////////////////
 
2
//
 
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).
 
6
//
 
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.
 
11
//
 
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.
 
16
//
 
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
 
20
// 02111-1307, USA.
 
21
////////////////////////////////////////////////////////////////////////////////
 
22
#include "tdwindow.h"
 
23
#include "tdviewer.h"
 
24
#include "tdtable.h"
 
25
#include "cellrow.h"
 
26
#include "cellcolumn.h"
 
27
#include "cell.h"
 
28
 
 
29
TDTable::TDTable(Config *c, TDWindow *t, TDViewer *v): Matrix(c, t, v) { }
 
30
 
 
31
bool TDTable::CheckTextString(Cell *c, const string *text) {
 
32
        return (Matrix::CheckTextString(c, text));
 
33
}
 
34
 
 
35
void TDTable::CheckDocument() {
 
36
        chkbuf = "";
 
37
        unsigned total = 0;
 
38
        // Check missing entity type names.
 
39
        unsigned n = CheckEmptyRowEntries(0);
 
40
        if (n > 0) {
 
41
                chkbuf += "* Error: ";
 
42
                chkbuf += n;
 
43
                chkbuf += " entity type";
 
44
                if (n!=1)
 
45
                        chkbuf += "s"; 
 
46
                chkbuf += " in column 0 ";
 
47
                (n == 1) ? (chkbuf += "is"): (chkbuf += "are");
 
48
                chkbuf += " still empty\n";
 
49
                total += n;
 
50
        }
 
51
        // Check missing transaction names.
 
52
        n = CheckEmptyColumnEntries(0);
 
53
        if (n > 0) {
 
54
                chkbuf += "* Error: ";
 
55
                chkbuf += n;
 
56
                chkbuf += " transaction";
 
57
                if (n!=1)
 
58
                        chkbuf += "s"; 
 
59
                chkbuf += " in row 0 ";
 
60
                (n == 1) ? (chkbuf += "is"): (chkbuf += "are");
 
61
                chkbuf += " still empty\n";
 
62
                total += n;
 
63
        }
 
64
        // Check for transactions without entries (warning).
 
65
        unsigned i;
 
66
        for (i=1; i<GetTableViewer()->GetNumberOfColumns(); i++) {
 
67
                CellColumn *column = GetTableViewer()->GiveColumn(i);
 
68
                if (column && *column->FirstCell()->GetText() != "") {
 
69
                        unsigned j = CheckEmptyRowEntries(i);
 
70
                        if (j == GetTableViewer()->GetNumberOfRows()-1) {
 
71
                                chkbuf+="* Warning: the transaction in column ";
 
72
                                chkbuf += i;
 
73
                                chkbuf += " does not do anything\n";
 
74
                                GetTableViewer()->SelectCell(column->FirstCell());
 
75
                                total += 1;
 
76
                        }
 
77
                }
 
78
        }
 
79
        // Check for entity types without entries(warning).
 
80
        for (i=1; i<GetTableViewer()->GetNumberOfRows(); i++) {
 
81
                CellRow *row = GetTableViewer()->GiveRow(i);
 
82
                if (row && *row->FirstCell()->GetText() != "") {
 
83
                        unsigned j = CheckEmptyColumnEntries(i);
 
84
                        if (j == GetTableViewer()->GetNumberOfColumns()-1) {
 
85
                                chkbuf += "* Warning: the entity type in row ";
 
86
                                chkbuf += i;
 
87
                                chkbuf += " does not take part in anything\n";
 
88
                                GetTableViewer()->SelectCell(row->FirstCell());
 
89
                                total += 1;
 
90
                        }
 
91
                }
 
92
        }
 
93
        ReportCheck(total, &chkbuf);
 
94
}