blob: 5f08c85526d457f6e41bb62fb56199956a7ab143 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.ui.admin.dbtabletab;
import java.util.ArrayList;
/**
* @author Donald G. Dunne
*/
public class DbModel {
private final ArrayList<Object> columns = new ArrayList<Object>();
private boolean needSave = false;
private final ArrayList<String> changedColumns = new ArrayList<String>();
public DbModel() {
}
public Object getColumn(int num) {
if (columns.isEmpty() || num > columns.size()) {
return "";
} else {
return columns.get(num);
}
}
public void addColumn(int column, Object obj) {
columns.add(column, obj);
}
public void setColumn(int column, Object obj) {
columns.set(column, obj);
}
public boolean isNeedSave() {
return needSave;
}
public void setNeedSave(boolean needSave) {
this.needSave = needSave;
}
public void setColumnChanged(String column) {
if (column == null) {
changedColumns.clear();
}
changedColumns.add(column);
}
public boolean isColumnChanged(String column) {
return changedColumns.contains(column);
}
public String[] getValues() {
String[] values = new String[columns.size()];
int x = 0;
for (Object o : columns) {
if (o instanceof String) {
values[x] = (String) o;
} else if (o instanceof Long) {
values[x] = ((Long) o).toString();
} else if (o == null) {
values[x] = "";
} else {
System.err.println("Invalid value type");
}
x++;
}
return values;
}
}
|